package edu.gatech.volt2.drdoommgt.presenter;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import edu.gatech.volt2.drdoommgt.domain.Patient;
import edu.gatech.volt2.drdoommgt.gui.IPatientHealthHistoryView;
import edu.gatech.volt2.drdoommgt.gui.PatientHealthHistoryView;
import edu.gatech.volt2.drdoommgt.system.DataBaseAccessor;

public class PatientHealthHistoryPresenter implements ActionListener{
	private DataBaseAccessor dba;
	private Patient myPatient;
	private IPatientHealthHistoryView myView;
	
	public PatientHealthHistoryPresenter(Patient patient, DataBaseAccessor db) {
		myPatient = patient;
		dba = db;
		myView = (IPatientHealthHistoryView) new PatientHealthHistoryView();
		myView.addListener(this);
		myView.showSelf();
		myView.setPatient(myPatient);

	}


	public PatientHealthHistoryPresenter(Patient patient) {
		myPatient = patient;
		myView = (IPatientHealthHistoryView) new PatientHealthHistoryView();
		myView.addListener(this);
		myView.setPatient(myPatient);
		myView.showSelf();
		
		dba = new DataBaseAccessor();
		dba.connectToDatabase();
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		if ( e.getSource() == myView.getCloseButton()){
			myView.hideSelf();
		}
	}
	
	
}